/*
 * ================================================================================变量定义区
 */
var param; //全局变量，保存防火墙信息

/*
 * ================================================================================页面初始化函数
 */
/**
 * 页面初始化方法
 */
$(function()
		{
			param = window.opener.param;
			initData();
		}
);

/*
 * ================================================================================函数定义区
 */
/**
 * 初始化页面展示数据
 */
function initData()
{
	var html = "";
	
	for(var i=0;i<param.length;i++)
	{
		var firewall = param[i];
		var doc = getHtml(firewall);
		html +=doc;
	}
	$('#firewall_title').after(html);
}

/**
 * 拼装每行要展示的防火墙信息的html
 * @param firewall
 * @returns {String}
 */
function getHtml(firewall)
{
	var html = "";
	var origIp = firewall.vdiIp;
	var ipArr = origIp.split(",");
	
	for(var i = 0;i<ipArr.length;i++)
	{
		var doc =  '<tr style="HEIGHT: 14.25pt;"><td style="border:1px solid #000;FONT-SIZE: 9pt;">'
			+ ipArr[i]+'</td>'
			+ '<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
			+firewall.targetIp+'</td>'
			+'<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
			+firewall.port+'('+firewall.protocol+')</td>'
			+'<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
			+firewall.remark+'</td></tr>';
		
		if(firewall.direction == 1)
		{
			doc =  '<tr style="HEIGHT: 14.25pt;"><td style="border:1px solid #000;FONT-SIZE: 9pt;">'
					+ firewall.targetIp+'</td>'
					+ '<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
					+ ipArr[i]+'</td>'
					+'<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
					+firewall.port+'('+firewall.protocol+')</td>'
					+'<td style="border:1px solid #000;FONT-SIZE: 9pt;">'
					+firewall.remark+'</td></tr>';
		}
		
		html +=doc;
	}
	return html;
}